<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="umsroot.css">
<TITLE>
Directives
</TITLE>
</HEAD>
<BODY >
<A HREF="umsroot031.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot028.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot033.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc68">6.4</A>&nbsp;&nbsp;Directives</H2><UL>
<LI><A HREF="umsroot032.html#toc38">Modules and Declarations</A>
<LI><A HREF="umsroot032.html#toc39">Conditional Compilation</A>
<LI><A HREF="umsroot032.html#toc40">Include Directives</A>
<LI><A HREF="umsroot032.html#toc41">Compiler Pragmas</A>
</UL>


<A NAME="toc38"></A>
<H3 CLASS="subsection"><A NAME="htoc69">6.4.1</A>&nbsp;&nbsp;Modules and Declarations</H3>

The following is a list of the directives most commonly used in source files:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<A HREF="../bips/kernel/modules/module-1.html"><B>:- module(Name).</B></A><A NAME="@default229"></A><DD CLASS="dd-description">
Beginning of a module.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/modules/module-3.html"><B>:- module(Name,Exports,Dialect).</B></A><A NAME="@default230"></A><DD CLASS="dd-description">
Beginning of a module in a given dialect.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/modules/local-1.html"><B>:- local Specs.</B></A><A NAME="@default231"></A><DD CLASS="dd-description">
Declaration of local items, e.g. syntax settings, operators, global storage, etc.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/modules/export-1.html"><B>:- export Specs.</B></A><A NAME="@default232"></A><DD CLASS="dd-description">
Declaration of local items, e.g. predicates, syntax settings, operators, etc.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/modules/reexport-1.html"><B>:- reexport Specs.</B></A><A NAME="@default233"></A><DD CLASS="dd-description">
Declaration of reexported items.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/modules/import-1.html"><B>:- import Specs.</B></A><A NAME="@default234"></A><DD CLASS="dd-description">
Declaration of imported modules or predicates.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/modules/use_module-1.html"><B>:- use_module(Mods).</B></A><A NAME="@default235"></A><DD CLASS="dd-description">
Loading and importing of modules or libraries.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/modules/lib-1.html"><B>:- lib(Libs).</B></A><A NAME="@default236"></A><DD CLASS="dd-description">
Loading and importing of libraries.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/termmanip/meta_attribute-2.html"><B>:- meta_attribute(Name,Handlers)</B></A><A NAME="@default237"></A><DD CLASS="dd-description">
Declare a variable attribute.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/directives/comment-2.html"><B>:- comment(Type,Info)</B></A><A NAME="@default238"></A><DD CLASS="dd-description">
Structured program documentation.
</DL>
<A NAME="toc39"></A>
<H3 CLASS="subsection"><A NAME="htoc70">6.4.2</A>&nbsp;&nbsp;Conditional Compilation</H3>

The compiler and other source-processing tools recognise the conditional
compilation directives if/1, elif/1, else/0 and endif/0. The first two
take a goal as their argument, and parts of the program source can be
included or excluded depending of the satisfiability of that goal. E.g.
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
:- if(get_flag(hostarch,"i386_nt")).
    ...Windows-specific code...
:- elif( (get_flag(version_as_list,Version), Version @&gt;= [6,0]) ).
    ...code for version 6.0 and later...
:- else.
    ...alternative code...
:- endif.
</PRE></BLOCKQUOTE>
Note however, that only complete clauses or directives can be
conditionally included.<BR>
<BR>
<A NAME="toc40"></A>
<H3 CLASS="subsection"><A NAME="htoc71">6.4.3</A>&nbsp;&nbsp;Include Directives</H3>
<A NAME="secinclude"></A>

Generally, it is best to use the module system to structure ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>
applications, and to use one module per file. The modules then refer
to each other via use_module/1, lib/1, or import/1 directives.
In rare cases it can make sense to split a single module into several
files, which can then be pulled together using the following include
directives:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<A HREF="../bips/kernel/directives/include-1.html"><B>:- include(Files).</B></A><A NAME="@default239"></A><DD CLASS="dd-description">
The contents of the given Files are treated as if they occurred in place of
the include directive. Files is a single file name or a list of them.<BR>
<BR>
<DT CLASS="dt-description"><A HREF="../bips/kernel/directives/D-2.html"><B>:- [Files].</B></A><A NAME="@default240"></A><DD CLASS="dd-description">
A synonym for the include/1 directive. Note that the semantics of this
construct when used as a directive (include semantics) differs slightly
from its use as a goal or query (compiler/loader invocation).
</DL>
Included files can contain clauses, directives and queries, but should
not contain module/1,3 directives, since they would be interpreted as
occurring within the including file, and the included module would
not end at the end of the included file.<BR>
<BR>
<A NAME="toc41"></A>
<H3 CLASS="subsection"><A NAME="htoc72">6.4.4</A>&nbsp;&nbsp;Compiler Pragmas</H3>
<A NAME="@default241"></A>
Compiler pragmas are compiler directives which instruct the compiler
to emit a particular code type, overriding the options given to the compiler.
Their syntax is similar to directives:
<BLOCKQUOTE CLASS="quote">
<PRE CLASS="verbatim">
:- pragma(Option).
</PRE></BLOCKQUOTE>
It is not possible to have several pragmas grouped together and separated
by commas, every pragma must be specified separately.
<I>Option</I> can be one of the following:
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B>debug</B><DD CLASS="dd-description"> - generate code which can be inspected with the
debugger.
This overrides the global setting of the <TT>debug_compile</TT> flag,
and any debug-option given to the compiler..<BR>
<BR>
<DT CLASS="dt-description"><B>nodebug</B><DD CLASS="dd-description"> - generate optimized code with no debugger support.
This overrides the global setting of the <TT>debug_compile</TT> flag,
and any debug-option given to the compiler.<BR>
<BR>
<DT CLASS="dt-description"><B>expand</B><DD CLASS="dd-description"> - do in-line expansion of built-ins 
like <A HREF="../bips/kernel/arithmetic/is-2.html"><B>is/2</B></A><A NAME="@default242"></A> and user-defined
inline predicates.
This code can still be inspected with the debugger but the expanded
subgoals look differently than in the normal debugged code,
or their arguments cannot be seen.
This pragma overrides the global setting of the <TT>goal_expansion</TT> flag,
and any expand-option given to the compiler.<BR>
<BR>
<DT CLASS="dt-description"><B>noexpand</B><DD CLASS="dd-description"> - inhibit the in-line goal expansion.
This pragma overrides the global setting of the <TT>goal_expansion</TT> flag,
and any expand-option given to the compiler.<BR>
<BR>
<DT CLASS="dt-description"><B>opt_level(Level)</B><DD CLASS="dd-description"> - override the opt_level option given to the
compiler. Level is an integer greater or equal to 0. A zero setting disables
all optional optimization.<BR>
<BR>
<DT CLASS="dt-description"><B>skip</B><DD CLASS="dd-description"> - set the <TT>skip</TT> flag of all following
predicates to <TT>on</TT>.<BR>
<BR>
<DT CLASS="dt-description"><B>noskip</B><DD CLASS="dd-description"> - set the <TT>skip</TT> flag of all following
predicates to <TT>off</TT>.<BR>
<BR>
<DT CLASS="dt-description"><B>system</B><DD CLASS="dd-description"> - set the <TT>type</TT> flag of all following
predicates to <TT>built_in</TT>.
Moreover, all following predicates will have unspecified
<TT>source_file</TT> and <TT>source_line</TT> flags.<BR>
<BR>
<DT CLASS="dt-description"><B>warnings</B><DD CLASS="dd-description"> - enable compiler warnings, overriding any
warnings-option given to the compiler.<BR>
<BR>
<DT CLASS="dt-description"><B>nowarnings</B><DD CLASS="dd-description"> - disable compiler warnings, overriding any
warnings-option given to the compiler.</DL>
A pragma is active from its specification in the file
until the file end or until it is disabled by another pragma.
Recursive compilations or calls to other compiling predicates
are not affected by the pragma.<BR>
<BR>
The pragmas are useful mainly for libraries and other programs
that should be always compiled in a particular mode
independently of the global flags or compiler option settings.<BR>
<BR>
<HR>
<A HREF="umsroot031.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot028.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="umsroot033.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
